<template>
  <div>
    <div class="index-header-box" id="head">
      <div class="index-header">
        <div @click="$router.back(-1)" class="back">
          <van-icon name="arrow-left"/>
        </div>
        <div class="title">客服中心</div>
      </div>
    </div>

    <div class="public-svr-box">
      <div class="wechat-head" v-if="info.svr_name">
        <img :src="img(info.svr_head)" class="head-img pull-left" />
        <div class="head-name pull-left">{{info.svr_name}}</div>
        <div class="head-tps pull-left">
          中国

          <img src="@/assets/images/user/svr.svg" alt="" class="tps-img">
        </div>
      </div>

      <div class="wechat-body">
        <img :src="img(info.svr_ewm)" alt="">
      </div>

      <div class="svr-tps">扫一扫或长按二维码图案，加我微信</div>

<!--      <div class="svr-tps1" v-if="info.svr_wechat">您专属客服微信号：{{info.svr_wechat}}</div>-->
<!--      <div class="svr-tps2" v-if="info.svr_wechat">客服电话:{{svrData.server_phone}}</div>-->
    </div>

    <a @click="copy" class="btn-svr svr-bg" id="copy" :data-clipboard-text="info.svr_wechat">点击复制客服微信号</a>
    <a :href="'tel:'+svrData.server_phone" class="btn-svr svr-bg"  >点击拨客服电话</a>

  </div>
</template>

<script>
    import Clipboard from 'clipboard'

  export default {
    name: "service",
    components: {
    },
    data() {
      return {
        info:[],
        svrData:[],
      }
    },
    computed: {},
    mounted: function () {
      this.init();
    },
    methods: {
      init(){
          this.$api.index.getServer().then(res=>{
              var res=res.data;

              this.info=res.data;
              this.svrData=res.data;
          });
      },

        //复制
        copy(){
            var _this = this;
            var clipboard = new Clipboard("#copy");

            clipboard.on('success', e => {
                _this.$toast("复制成功！");
                // 释放内存
                clipboard.destroy()
            })
            clipboard.on('error', e => {
                // 不支持复制
                _this.$toast("该浏览器不支持自动复制！");
                // 释放内存
                clipboard.destroy()
            })
        },
    },
  }
</script>
